| Conditions | 1 |
| Paths | 1 |
| Total Lines | 584 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var chai = require('chai'); |
||
| 8 | describe('GedcomX', function(){ |
||
| 9 | |||
| 10 | var fullJSON = { |
||
| 11 | id: 'gedcomx', |
||
| 12 | attribution: { |
||
| 13 | changeMessage: 'It changed', |
||
| 14 | contributor: { resource: 'https://myapp.com/contributor'}, |
||
| 15 | created: 1111338494969, |
||
| 16 | creator: { resource: 'https://myapp.com/creator'}, |
||
| 17 | modified: 1111338494969 |
||
| 18 | }, |
||
| 19 | persons: [ |
||
| 20 | { |
||
| 21 | private: false, |
||
| 22 | gender: { |
||
| 23 | type: 'http://gedcomx.org/Female' |
||
| 24 | }, |
||
| 25 | names: [ |
||
| 26 | { |
||
| 27 | type: 'http://gedcomx.org/BirthName', |
||
| 28 | nameForms: [ |
||
| 29 | { |
||
| 30 | fullText: 'Joanna Hopkins' |
||
| 31 | } |
||
| 32 | ] |
||
| 33 | } |
||
| 34 | ], |
||
| 35 | facts: [ |
||
| 36 | { |
||
| 37 | type: 'http://gedcomx.org/Birth', |
||
| 38 | date: { |
||
| 39 | formal: '+2001-04-09' |
||
| 40 | }, |
||
| 41 | place: { |
||
| 42 | original: 'Farm house' |
||
| 43 | } |
||
| 44 | } |
||
| 45 | ] |
||
| 46 | } |
||
| 47 | ], |
||
| 48 | relationships: [ |
||
| 49 | { |
||
| 50 | type: 'http://gedcomx.org/Couple', |
||
| 51 | person1: { |
||
| 52 | resource: 'http://identifier/for/person/1' |
||
| 53 | }, |
||
| 54 | person2: { |
||
| 55 | resource: 'http://identifier/for/person/2' |
||
| 56 | }, |
||
| 57 | facts: [ |
||
| 58 | { |
||
| 59 | type: 'http://gedcomx.org/Marriage' |
||
| 60 | } |
||
| 61 | ] |
||
| 62 | } |
||
| 63 | ], |
||
| 64 | sourceDescriptions: [ |
||
| 65 | { |
||
| 66 | resourceType: 'http://some/type', |
||
| 67 | citations: [ |
||
| 68 | { |
||
| 69 | lang: 'en', |
||
| 70 | value: 'Long source citation' |
||
| 71 | } |
||
| 72 | ], |
||
| 73 | mediaType: 'book', |
||
| 74 | about: 'http://a/resource', |
||
| 75 | mediator: { |
||
| 76 | resource: 'http://mediator' |
||
| 77 | }, |
||
| 78 | sources: [ |
||
| 79 | { |
||
| 80 | description: 'http://source/reference' |
||
| 81 | } |
||
| 82 | ], |
||
| 83 | analysis: { |
||
| 84 | resource: 'http://analysis' |
||
| 85 | }, |
||
| 86 | componentOf: { |
||
| 87 | description: 'http://container' |
||
| 88 | }, |
||
| 89 | titles: [ |
||
| 90 | { |
||
| 91 | lang: 'en', |
||
| 92 | value: 'Title' |
||
| 93 | }, |
||
| 94 | { |
||
| 95 | lang: 'es', |
||
| 96 | value: 'Titulo' |
||
| 97 | } |
||
| 98 | ], |
||
| 99 | notes: [ |
||
| 100 | { |
||
| 101 | subject: 'Note', |
||
| 102 | text: 'Some note text' |
||
| 103 | } |
||
| 104 | ], |
||
| 105 | attribution: { |
||
| 106 | created: 1234578129 |
||
| 107 | }, |
||
| 108 | rights: [ |
||
| 109 | { |
||
| 110 | resource: 'https://some/right' |
||
| 111 | } |
||
| 112 | ], |
||
| 113 | coverage: { |
||
| 114 | temporal: { |
||
| 115 | formal: '+2015' |
||
| 116 | }, |
||
| 117 | spatial: { |
||
| 118 | original: 'A place' |
||
| 119 | } |
||
| 120 | }, |
||
| 121 | descriptions: [ |
||
| 122 | { |
||
| 123 | value: 'A description' |
||
| 124 | } |
||
| 125 | ], |
||
| 126 | identifiers: { |
||
| 127 | $: 'identifier' |
||
| 128 | }, |
||
| 129 | created: 1000000, |
||
| 130 | modified: 11111111, |
||
| 131 | repository: { |
||
| 132 | resource: 'http://repository' |
||
| 133 | } |
||
| 134 | } |
||
| 135 | ], |
||
| 136 | agents: [ |
||
| 137 | { |
||
| 138 | id: 'agent', |
||
| 139 | identifiers: { |
||
| 140 | $: 'ident' |
||
| 141 | }, |
||
| 142 | names: [ |
||
| 143 | { |
||
| 144 | lang: 'en', |
||
| 145 | value: 'Name' |
||
| 146 | } |
||
| 147 | ], |
||
| 148 | homepage: { |
||
| 149 | resource: 'http://homepage' |
||
| 150 | }, |
||
| 151 | openid: { |
||
| 152 | resource: 'http://openid' |
||
| 153 | }, |
||
| 154 | accounts: [ |
||
| 155 | { |
||
| 156 | accountName: 'jimbo' |
||
| 157 | } |
||
| 158 | ], |
||
| 159 | emails: [ |
||
| 160 | { |
||
| 161 | resource: 'http://email' |
||
| 162 | } |
||
| 163 | ], |
||
| 164 | phones: [ |
||
| 165 | { |
||
| 166 | resource: 'http://phone' |
||
| 167 | } |
||
| 168 | ], |
||
| 169 | addresses: [ |
||
| 170 | { |
||
| 171 | value: 'big long address', |
||
| 172 | postalCode: '123456' |
||
| 173 | } |
||
| 174 | ], |
||
| 175 | person: { |
||
| 176 | resource: 'http://person' |
||
| 177 | } |
||
| 178 | } |
||
| 179 | ], |
||
| 180 | events: [ |
||
| 181 | { |
||
| 182 | type: 'http://gedcomx.org/Marriage', |
||
| 183 | date: { |
||
| 184 | formal: '+2002-06-06' |
||
| 185 | }, |
||
| 186 | place: { |
||
| 187 | original: 'Her town, MN' |
||
| 188 | }, |
||
| 189 | roles: [ |
||
| 190 | { |
||
| 191 | person: { |
||
| 192 | resource: 'http://groom' |
||
| 193 | }, |
||
| 194 | type: 'http://gedcomx.org/Participant' |
||
| 195 | } |
||
| 196 | ] |
||
| 197 | } |
||
| 198 | ], |
||
| 199 | documents: [ |
||
| 200 | { |
||
| 201 | type: 'http://gedcomx.org/Abstract', |
||
| 202 | extracted: false, |
||
| 203 | textType: 'plain', |
||
| 204 | text: 'Lots of text', |
||
| 205 | attribution: { |
||
| 206 | created: 123456789 |
||
| 207 | } |
||
| 208 | } |
||
| 209 | ], |
||
| 210 | places: [ |
||
| 211 | { |
||
| 212 | names : [ |
||
| 213 | { |
||
| 214 | lang : 'en', |
||
| 215 | value : 'Pope\'s Creek, Westmoreland, Virginia, United States' |
||
| 216 | } |
||
| 217 | ], |
||
| 218 | type : 'http://identifier/for/the/place/type', |
||
| 219 | place : { resource : 'http://place' }, |
||
| 220 | jurisdiction : { resource : 'http://jurisdiction' }, |
||
| 221 | latitude : 27.9883575, |
||
| 222 | longitude : 86.9252014, |
||
| 223 | temporalDescription : { |
||
| 224 | formal: '+1899-01-04' |
||
| 225 | }, |
||
| 226 | spatialDescription : { |
||
| 227 | resource : 'http://uri/for/KML/document' |
||
| 228 | } |
||
| 229 | } |
||
| 230 | ] |
||
| 231 | }; |
||
| 232 | |||
| 233 | it('Create plain', function(){ |
||
| 234 | var newGedx = new GedcomX(), |
||
| 235 | gedx = GedcomX(); |
||
| 236 | assert.instanceOf(newGedx, GedcomX, 'An instance of GedcomX is not returned when calling the constructor with new.'); |
||
| 237 | assert.instanceOf(gedx, GedcomX, 'An instance of GedcomX is not returned when calling the constructor without new.'); |
||
| 238 | assert.jsonSchema(newGedx.toJSON(), GedcomXSchema); |
||
| 239 | assert.jsonSchema(gedx.toJSON(), GedcomXSchema); |
||
| 240 | }); |
||
| 241 | |||
| 242 | it('Create with JSON', function(){ |
||
| 243 | var gedx = GedcomX(fullJSON); |
||
| 244 | tests(gedx); |
||
| 245 | }); |
||
| 246 | |||
| 247 | it('Create with mixed data', function(){ |
||
| 248 | var gedx = GedcomX({ |
||
| 249 | id: 'gedcomx', |
||
| 250 | attribution: GedcomX.Attribution({ |
||
| 251 | changeMessage: 'It changed', |
||
| 252 | contributor: GedcomX.ResourceReference({ resource: 'https://myapp.com/contributor'}), |
||
| 253 | created: new Date(1111338494969), |
||
| 254 | creator: GedcomX.ResourceReference({ resource: 'https://myapp.com/creator'}), |
||
| 255 | modified: new Date(1111338494969) |
||
| 256 | }), |
||
| 257 | persons: [ |
||
| 258 | GedcomX.Person({ |
||
| 259 | gender: { |
||
| 260 | type: 'http://gedcomx.org/Female' |
||
| 261 | }, |
||
| 262 | names: [ |
||
| 263 | { |
||
| 264 | type: 'http://gedcomx.org/BirthName', |
||
| 265 | nameForms: [ |
||
| 266 | { |
||
| 267 | fullText: 'Joanna Hopkins' |
||
| 268 | } |
||
| 269 | ] |
||
| 270 | } |
||
| 271 | ], |
||
| 272 | facts: [ |
||
| 273 | { |
||
| 274 | type: 'http://gedcomx.org/Birth', |
||
| 275 | date: { |
||
| 276 | formal: '+2001-04-09' |
||
| 277 | }, |
||
| 278 | place: { |
||
| 279 | original: 'Farm house' |
||
| 280 | } |
||
| 281 | } |
||
| 282 | ] |
||
| 283 | }) |
||
| 284 | ], |
||
| 285 | relationships: [ |
||
| 286 | GedcomX.Relationship({ |
||
| 287 | type: 'http://gedcomx.org/Couple', |
||
| 288 | person1: { |
||
| 289 | resource: 'http://identifier/for/person/1' |
||
| 290 | }, |
||
| 291 | person2: { |
||
| 292 | resource: 'http://identifier/for/person/2' |
||
| 293 | }, |
||
| 294 | facts: [ |
||
| 295 | GedcomX.Fact({ |
||
| 296 | type: 'http://gedcomx.org/Marriage' |
||
| 297 | }) |
||
| 298 | ] |
||
| 299 | }) |
||
| 300 | ], |
||
| 301 | sourceDescriptions: [ |
||
| 302 | GedcomX.SourceDescription({ |
||
| 303 | resourceType: 'http://some/type', |
||
| 304 | citations: [ |
||
| 305 | GedcomX.SourceCitation({ |
||
| 306 | lang: 'en', |
||
| 307 | value: 'Long source citation' |
||
| 308 | }) |
||
| 309 | ], |
||
| 310 | mediaType: 'book', |
||
| 311 | about: 'http://a/resource', |
||
| 312 | mediator: { |
||
| 313 | resource: 'http://mediator' |
||
| 314 | }, |
||
| 315 | sources: [ |
||
| 316 | GedcomX.SourceReference({ |
||
| 317 | description: 'http://source/reference' |
||
| 318 | }) |
||
| 319 | ], |
||
| 320 | analysis: { |
||
| 321 | resource: 'http://analysis' |
||
| 322 | }, |
||
| 323 | componentOf: { |
||
| 324 | description: 'http://container' |
||
| 325 | }, |
||
| 326 | titles: [ |
||
| 327 | GedcomX.TextValue({ |
||
| 328 | lang: 'en', |
||
| 329 | value: 'Title' |
||
| 330 | }), |
||
| 331 | { |
||
| 332 | lang: 'es', |
||
| 333 | value: 'Titulo' |
||
| 334 | } |
||
| 335 | ], |
||
| 336 | notes: [ |
||
| 337 | GedcomX.Note({ |
||
| 338 | subject: 'Note', |
||
| 339 | text: 'Some note text' |
||
| 340 | }) |
||
| 341 | ], |
||
| 342 | attribution: { |
||
| 343 | created: 1234578129 |
||
| 344 | }, |
||
| 345 | rights: [ |
||
| 346 | GedcomX.ResourceReference({ |
||
| 347 | resource: 'https://some/right' |
||
| 348 | }) |
||
| 349 | ], |
||
| 350 | coverage: GedcomX.Coverage({ |
||
| 351 | temporal: { |
||
| 352 | formal: '+2015' |
||
| 353 | }, |
||
| 354 | spatial: { |
||
| 355 | original: 'A place' |
||
| 356 | } |
||
| 357 | }), |
||
| 358 | descriptions: [ |
||
| 359 | { |
||
| 360 | value: 'A description' |
||
| 361 | } |
||
| 362 | ], |
||
| 363 | identifiers: { |
||
| 364 | $: 'identifier' |
||
| 365 | }, |
||
| 366 | created: 1000000, |
||
| 367 | modified: 11111111, |
||
| 368 | repository: GedcomX.ResourceReference({ |
||
| 369 | resource: 'http://repository' |
||
| 370 | }) |
||
| 371 | }) |
||
| 372 | ], |
||
| 373 | agents: [ |
||
| 374 | GedcomX.Agent({ |
||
| 375 | id: 'agent', |
||
| 376 | identifiers: GedcomX.Identifiers({ |
||
| 377 | $: 'ident' |
||
| 378 | }), |
||
| 379 | names: [ |
||
| 380 | GedcomX.TextValue({ |
||
| 381 | lang: 'en', |
||
| 382 | value: 'Name' |
||
| 383 | }) |
||
| 384 | ], |
||
| 385 | homepage: GedcomX.ResourceReference({ |
||
| 386 | resource: 'http://homepage' |
||
| 387 | }), |
||
| 388 | openid: GedcomX.ResourceReference({ |
||
| 389 | resource: 'http://openid' |
||
| 390 | }), |
||
| 391 | accounts: [ |
||
| 392 | GedcomX.OnlineAccount({ |
||
| 393 | accountName: 'jimbo' |
||
| 394 | }) |
||
| 395 | ], |
||
| 396 | emails: [ |
||
| 397 | GedcomX.ResourceReference({ |
||
| 398 | resource: 'http://email' |
||
| 399 | }) |
||
| 400 | ], |
||
| 401 | phones: [ |
||
| 402 | GedcomX.ResourceReference({ |
||
| 403 | resource: 'http://phone' |
||
| 404 | }) |
||
| 405 | ], |
||
| 406 | addresses: [ |
||
| 407 | GedcomX.Address({ |
||
| 408 | value: 'big long address', |
||
| 409 | postalCode: '123456' |
||
| 410 | }) |
||
| 411 | ], |
||
| 412 | person: GedcomX.ResourceReference({ |
||
| 413 | resource: 'http://person' |
||
| 414 | }) |
||
| 415 | }) |
||
| 416 | ], |
||
| 417 | events: [ |
||
| 418 | GedcomX.Event({ |
||
| 419 | type: 'http://gedcomx.org/Marriage', |
||
| 420 | date: GedcomX.Date({ |
||
| 421 | formal: '+2002-06-06' |
||
| 422 | }), |
||
| 423 | place: GedcomX.PlaceReference({ |
||
| 424 | original: 'Her town, MN' |
||
| 425 | }), |
||
| 426 | roles: [ |
||
| 427 | GedcomX.EventRole({ |
||
| 428 | person: { |
||
| 429 | resource: 'http://groom' |
||
| 430 | }, |
||
| 431 | type: 'http://gedcomx.org/Participant' |
||
| 432 | }) |
||
| 433 | ] |
||
| 434 | }) |
||
| 435 | ], |
||
| 436 | documents: [ |
||
| 437 | GedcomX.Document({ |
||
| 438 | type: 'http://gedcomx.org/Abstract', |
||
| 439 | extracted: false, |
||
| 440 | textType: 'plain', |
||
| 441 | text: 'Lots of text', |
||
| 442 | attribution: GedcomX.Attribution({ |
||
| 443 | created: 123456789 |
||
| 444 | }) |
||
| 445 | }) |
||
| 446 | ], |
||
| 447 | places: [ |
||
| 448 | GedcomX.PlaceDescription({ |
||
| 449 | names : [ |
||
| 450 | GedcomX.TextValue({ |
||
| 451 | lang : 'en', |
||
| 452 | value : 'Pope\'s Creek, Westmoreland, Virginia, United States' |
||
| 453 | }) |
||
| 454 | ], |
||
| 455 | type : 'http://identifier/for/the/place/type', |
||
| 456 | place : GedcomX.ResourceReference({ resource : 'http://place' }), |
||
| 457 | jurisdiction : GedcomX.ResourceReference({ resource : 'http://jurisdiction' }), |
||
| 458 | latitude : 27.9883575, |
||
| 459 | longitude : 86.9252014, |
||
| 460 | temporalDescription : GedcomX.Date({ |
||
| 461 | formal: '+1899-01-04' |
||
| 462 | }), |
||
| 463 | spatialDescription : GedcomX.ResourceReference({ |
||
| 464 | resource : 'http://uri/for/KML/document' |
||
| 465 | }) |
||
| 466 | }) |
||
| 467 | ] |
||
| 468 | }); |
||
| 469 | |||
| 470 | tests(gedx); |
||
| 471 | }); |
||
| 472 | |||
| 473 | it('Build', function(){ |
||
| 474 | var gedx = GedcomX() |
||
| 475 | .setId('gedcomx') |
||
| 476 | .setAttribution(GedcomX.Attribution() |
||
| 477 | .setChangeMessage('It changed') |
||
| 478 | .setContributor({ resource: 'https://myapp.com/contributor'}) |
||
| 479 | .setCreated(1111338494969) |
||
| 480 | .setCreator({ resource: 'https://myapp.com/creator'}) |
||
| 481 | .setModified(1111338494969)) |
||
| 482 | .addPerson( |
||
| 483 | GedcomX.Person() |
||
| 484 | .setId('testPerson') |
||
| 485 | .setPrivate(true) |
||
| 486 | .setGender(GedcomX.Gender().setType('http://gedcomx.org/Female')) |
||
| 487 | .addName(GedcomX.Name().addNameForm(GedcomX.NameForm().setFullText('Joanna Hopkins'))) |
||
| 488 | .addFact(GedcomX.Fact().setDate(GedcomX.Date().setFormal('+2001-04-09')).setPlace(GedcomX.PlaceReference().setOriginal('Farm house'))) |
||
| 489 | ) |
||
| 490 | .addRelationship( |
||
| 491 | GedcomX.Relationship() |
||
| 492 | .setType('http://gedcomx.org/Couple') |
||
| 493 | .setPerson1(GedcomX.ResourceReference().setResource('http://identifier/for/person/1')) |
||
| 494 | .setPerson2(GedcomX.ResourceReference().setResource('http://identifier/for/person/2')) |
||
| 495 | .addFact(GedcomX.Fact().setType('http://gedcomx.org/Marriage')) |
||
| 496 | ) |
||
| 497 | .addSourceDescription( |
||
| 498 | GedcomX.SourceDescription() |
||
| 499 | .setResourceType('http://some/type') |
||
| 500 | .addCitation(GedcomX.SourceCitation().setLang('en').setValue('Long source citation')) |
||
| 501 | .setMediaType('book') |
||
| 502 | .setAbout('http://a/resource') |
||
| 503 | .setMediator(GedcomX.ResourceReference().setResource('http://mediator')) |
||
| 504 | .addSource(GedcomX.SourceReference().setDescription('http://source/reference')) |
||
| 505 | .setAnalysis(GedcomX.ResourceReference().setResource('http://analysis')) |
||
| 506 | .setComponentOf(GedcomX.SourceReference().setDescription('http://container')) |
||
| 507 | .addTitle(GedcomX.TextValue().setLang('en').setValue('Title')) |
||
| 508 | .addTitle(GedcomX.TextValue().setLang('es').setValue('Titulo')) |
||
| 509 | .addNote(GedcomX.Note().setSubject('Note').setText('Some note text')) |
||
| 510 | .setAttribution(GedcomX.Attribution().setCreated(1234578129)) |
||
| 511 | .addRight(GedcomX.ResourceReference().setResource('https://some/right')) |
||
| 512 | .setCoverage( |
||
| 513 | GedcomX.Coverage() |
||
| 514 | .setTemporal(GedcomX.Date().setFormal('+2015')) |
||
| 515 | .setSpatial(GedcomX.PlaceReference().setOriginal('A place')) |
||
| 516 | ) |
||
| 517 | .addDescription(GedcomX.TextValue().setValue('A description')) |
||
| 518 | .setIdentifiers(GedcomX.Identifiers({ |
||
| 519 | $: 'identifier' |
||
| 520 | })) |
||
| 521 | .setCreated(1000000) |
||
| 522 | .setModified(11111111) |
||
| 523 | .setRepository(GedcomX.ResourceReference().setResource('http://repository')) |
||
| 524 | ) |
||
| 525 | .addAgent( |
||
| 526 | GedcomX.Agent() |
||
| 527 | .setId('agent') |
||
| 528 | .setIdentifiers(GedcomX.Identifiers({$:'ident'})) |
||
| 529 | .addName(GedcomX.TextValue().setLang('en').setValue('Name')) |
||
| 530 | .setHomepage(GedcomX.ResourceReference().setResource('http://homepage')) |
||
| 531 | .setOpenid(GedcomX.ResourceReference().setResource('http://openid')) |
||
| 532 | .addAccount(GedcomX.OnlineAccount().setAccountName('jimbo')) |
||
| 533 | .addEmail(GedcomX.ResourceReference().setResource('http://email')) |
||
| 534 | .addPhone(GedcomX.ResourceReference().setResource('http://phone')) |
||
| 535 | .addAddress(GedcomX.Address().setValue('big long address').setPostalCode('123456')) |
||
| 536 | .setPerson(GedcomX.ResourceReference().setResource('http://person')) |
||
| 537 | ) |
||
| 538 | .addEvent( |
||
| 539 | GedcomX.Event() |
||
| 540 | .setType('http://gedcomx.org/Marriage') |
||
| 541 | .setDate(GedcomX.Date().setFormal('+2002-06-06')) |
||
| 542 | .setPlace(GedcomX.PlaceReference().setOriginal('Her town, MN')) |
||
| 543 | .addRole(GedcomX.EventRole() |
||
| 544 | .setType('http://gedcomx.org/Participant') |
||
| 545 | .setPerson(GedcomX.ResourceReference().setResource('http://groom'))) |
||
| 546 | ) |
||
| 547 | .addDocument( |
||
| 548 | GedcomX.Document() |
||
| 549 | .setType('http://gedcomx.org/Abstract') |
||
| 550 | .setExtracted(false) |
||
| 551 | .setTextType('plain') |
||
| 552 | .setText('Lots of text') |
||
| 553 | .setAttribution(GedcomX.Attribution().setCreated(123456789)) |
||
| 554 | ) |
||
| 555 | .addPlace( |
||
| 556 | GedcomX.PlaceDescription() |
||
| 557 | .addName(GedcomX.TextValue().setLang('en').setValue('Pope\'s Creek, Westmoreland, Virginia, United States')) |
||
| 558 | .setType('http://identifier/for/the/place/type') |
||
| 559 | .setPlace(GedcomX.ResourceReference({ resource : 'http://place' })) |
||
| 560 | .setJurisdiction(GedcomX.ResourceReference({ resource : 'http://jurisdiction' })) |
||
| 561 | .setLatitude(27.9883575) |
||
| 562 | .setLongitude(86.9252014) |
||
| 563 | .setTemporalDescription(GedcomX.Date({ |
||
| 564 | formal: '+1899-01-04' |
||
| 565 | })) |
||
| 566 | .setSpatialDescription(GedcomX.ResourceReference({ |
||
| 567 | resource : 'http://uri/for/KML/document' |
||
| 568 | })) |
||
| 569 | ); |
||
| 570 | |||
| 571 | tests(gedx); |
||
| 572 | }); |
||
| 573 | |||
| 574 | it('toJSON', function(){ |
||
| 575 | var gedx = GedcomX(fullJSON); |
||
| 576 | assert.deepEqual(gedx.toJSON(), fullJSON); |
||
| 577 | assert.jsonSchema(gedx.toJSON(), GedcomXSchema); |
||
| 578 | }); |
||
| 579 | |||
| 580 | it('adding Person does not copy', function(){ |
||
| 581 | var gedx = GedcomX(); |
||
| 582 | var person = GedcomX.Person({ |
||
| 583 | id: 'first' |
||
| 584 | }); |
||
| 585 | gedx.addPerson(person); |
||
| 586 | person.setId('second'); |
||
| 587 | assert.strictEqual(gedx.getPersons()[0], person, 'the added instance is not the same as the original instance'); |
||
| 588 | assert.deepEqual(gedx.getPersons()[0].toJSON(), person.toJSON(), 'serialization of the added person does not match the original person'); |
||
| 589 | }); |
||
| 590 | |||
| 591 | }); |
||
| 592 | |||
| 701 | } |